﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KCMS.DataAcsess.Interfaces;
using StructureMap;
using AutoMapper;
using KCMS.BusinessLogic.Models;
using KCMS.BusinessLogic.Interfaces;


namespace KCMS.BusinessLogic.Engine
{
    public class OrderDeliveryService : IOrderDeliveryService
    {
        private IOrderDeliveryManager orderDeliveryManager = ObjectFactory.GetInstance<IOrderDeliveryManager>();
        public Models.OrderDelivery getById(Guid id)
        {
            DataAcsess.Entitys.OrderDeliveryEntity orderDeliveryEntity = orderDeliveryManager.getById(id);
            return Mapper.Map<DataAcsess.Entitys.OrderDeliveryEntity, Models.OrderDelivery>(orderDeliveryEntity);
        }

        public IEnumerable<Models.OrderDelivery> getAll()
        {
            var model = from t in orderDeliveryManager.getAll()
                        select t;
            return Mapper.Map<IEnumerable<DataAcsess.Entitys.OrderDeliveryEntity>, IEnumerable<Models.OrderDelivery>>(model);

        }

        public void update(OrderDelivery orderDelivery)
        {
            orderDeliveryManager.update(Mapper.Map<OrderDelivery, DataAcsess.Entitys.OrderDeliveryEntity>(orderDelivery));
        }


        public void save(OrderDelivery orderDelivery)
        {
          
           
            orderDeliveryManager.save(Mapper.Map<OrderDelivery, DataAcsess.Entitys.OrderDeliveryEntity>(orderDelivery));
        }


        public void delete(Guid id)
        {
            orderDeliveryManager.delete(id);
        }

    }
}
